package com.mogujie.tt.DB.sp;

import android.content.Context;
import android.content.SharedPreferences;
import android.text.TextUtils;

/**
 * Created by user on 2015/10/28.
 */
public class NewFriendsSp {
    private final String fileName = "newfriends.ini";
    private Context ctx;
    private final String KEY_REQUEST_ADD_BUDDY  = "requestAddBuddy";

    SharedPreferences sharedPreferences;

    private static NewFriendsSp newFriendsSp = null;
    public static NewFriendsSp instance(){
        if(newFriendsSp ==null){
            synchronized (LoginSp.class){
                newFriendsSp = new NewFriendsSp();
            }
        }
        return newFriendsSp;
    }
    private NewFriendsSp(){
    }

    public void  init(Context ctx){
        this.ctx = ctx;
        sharedPreferences= ctx.getSharedPreferences
                (fileName,ctx.MODE_PRIVATE);
    }

    public  void setNewFriendsInfo(int requestAddBuddy){
        // 横写
        SharedPreferences.Editor editor = sharedPreferences.edit();
        editor.putInt(KEY_REQUEST_ADD_BUDDY, requestAddBuddy);
        //提交当前数据
        editor.commit();
    }


    public SpNewFriends getNewFriends(){
        int requestAddBuddy =  sharedPreferences.getInt(KEY_REQUEST_ADD_BUDDY,0);

        return new SpNewFriends(requestAddBuddy);
    }

    public class SpNewFriends {

        private int requestAddBuddy;

        public SpNewFriends(int mRequestAddBuddy) {
            requestAddBuddy = mRequestAddBuddy;

        }

        public int getRequestAddBuddy() {
            return requestAddBuddy;
        }

        public void setRequestAddBuddy(int requestAddBuddy) {
            this.requestAddBuddy = requestAddBuddy;
        }
    }
}
